package com.nelson.infraredcontrol.business.home;

import android.app.Application;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import com.nelson.infraredcontrol.base.Resource;

/**
 * @author nelson
 * @since 2020-09-05
 */
public class MainViewModel extends AndroidViewModel {

    public MainViewModel(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<Resource<Boolean>> fetchRemoteData() {
        final MutableLiveData<Resource<Boolean>> response = new MutableLiveData<>();

        response.postValue(Resource.loading(false));

        // do something
        new Thread(new Runnable() {
            @Override
            public void run() {
                SystemClock.sleep(3000);

                response.postValue(Resource.success(true));
            }
        }).start();

        return response;
    }
}